package per.hx.bs.topic.sender.Impl;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import per.hx.bs.base.entity.EmailVO;
import per.hx.bs.constant.TopicRabbit;
import per.hx.bs.topic.sender.TopicSender;

/**
 * @author HuXing
 * @date 2018/4/26  15:38
 */
@Component
public class TopicSenderImpl implements TopicSender {

    private final AmqpTemplate rabbitTemplate;

    @Autowired
    public TopicSenderImpl(AmqpTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @Override
    public int send(EmailVO emailVO) {
        this.rabbitTemplate.convertAndSend("topicExchange", TopicRabbit.EMAIL, emailVO);
        return 0;
    }
}
